<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>胜平负</title>
    <script src="../static/js/jquery-3.7.1.min.js" type="text/javascript"></script>
    <style>
    table {
        border-collapse: collapse; /*合并边框*/
        width: 100%; /*设置表格宽度*/
    }

    th, td {
        border: 1px solid black; /*设置边框线样式、颜色和大小*/
        padding: 8px; /*设置内边距*/
    }
        .p1{
                background-color: red;
        }
        .p2{
            background-color: magenta;
        }
        .p3{
            background-color: green;
        }
        .p4{
            background-color: mediumturquoise;
        }
        .p5{
            background-color: orange;
        }
        .p6{
            background-color: royalblue;
        }
        .p7{
            background-color: palevioletred;
        }.p8{
            background-color: brown;
        }
        .peid{
            background-color: gray;
        }
        .qiu{
            background-color: darkcyan;
        }
</style>

</head>
<body>
<table id="t">
<thead>
<tr>
    <td>开赛时间</td>
    <td>类型</td>
    <td>比赛</td>
    <td>场次</td>
    <td>让球</td>
    <td class="qiu">胜</td>
    <td class="qiu">平</td>
    <td class="qiu">负</td>
    <td class='peid'>一赔</td>
    <td class='peid'>二赔</td>
    <td class='peid'>三赔</td>
    <td class="qiu">让胜</td>
    <td class="qiu">让平</td>
    <td class="qiu">让负</td>
    <td class='peid'>一赔</td>
    <td class='peid'>二赔</td>
    <td class='peid'>三赔</td>
    <td>推荐</td>
    <td>操作</td>
</tr>
</thead>
</table>
</body>

<script type="text/javascript">
        $(function () {
            // 获取后台数据
            $.get('/getselling_hda', function(res) {
                var arr = new Array();
                var total = res.length; //总

                for(var i=0;i<total;i++) {
                    arr.push("<tr>");
                    arr.push("<td colspan='20'>");arr.push("竞猜日期:"+res[i].businessDate);arr.push("</td>");
                    arr.push("</tr>");
                    for (var j = 0; j < res[i].datas.length; j++) {
                        var d = res[i].datas[j];


                                                                        //单关显示
                        var singleList = d.singleList;
                        var showsing = "";
                        if (singleList.includes("HAD")){//说明有胜平负单关
                            showsing = "单关";
                        }
                        if (singleList.includes("HHAD")){//说明有让球胜平负单关
                            showsing = "让球单关";
                        }

                        arr.push("<tr>");
                        arr.push("<td>");arr.push(d.matchDate);arr.push(d.matchTime);arr.push("</td>");
                        arr.push("<td>");arr.push(d.leagueAbbName);arr.push("</td>");
                        arr.push("<td>");arr.push(d.homeTeamAbbName+"vs"+d.awayTeamAbbName);arr.push("</td>");
                        arr.push("<td>");arr.push(d.NO);arr.push("&nbsp;&nbsp;"+showsing);arr.push("</td>");
                        arr.push("<td>");arr.push(d.goalLine);arr.push("</td>");
                        // 胜平负
                        var spfv = d.spfv;
                        var peid_spf = d.peid_spf;


                        for (var a = 0; a < spfv.length; a++) {
                            //按胜平负来显示
                            arr.push("<td>");
                            arr.push(spfv[a]);
                            arr.push("</td>");
                        }
                        for (var a = 0; a < peid_spf.length; a++) {
                            //按赔来显示
                            arr.push("<td>");
                            arr.push(hadTospf(peid_spf[a][0],"spf"));
                            arr.push("</td>");
                        }

                        // 让球胜平负
                        var hspfv = d.hspfv;
                        var peid_hspf = d.peid_hspf;


                        for (var a = 0; a < hspfv.length; a++) {
                            //按胜平负来显示
                            arr.push("<td>");
                            arr.push(hspfv[a]);
                            arr.push("</td>");
                        }
                        for (var a = 0; a < peid_hspf.length; a++) {
                            //按赔来显示
                            arr.push("<td>");
                            arr.push(hadTospf(peid_hspf[a][0],"hspf"));
                            arr.push("</td>");
                        }

                        arr.push("<td>");arr.push("");arr.push("</td>");
                        var detail = "<a href='/hda?tp=selling&matchId="+d.matchId+"' target=\"_blank\">"+d.NO+"  同赔</a>";
                        arr.push("<td>");arr.push(detail);arr.push("</td>");
                        arr.push("</tr>");
                    }
                }
                $("#t").append(arr.join(" "))
                });

            });
                   //h：胜，d:平，a：负
    function hadTospf(a,tp) {
        var r = "-";
        if(tp == 'hspf'){
            if(a=='h'){
                r = '让胜';
            }
            else if(a=='d'){
                r = '让平';
            }
            else if(a=='a'){
                r = '让负';
            }
        }else {
            if(a=='h'){
                r = '胜';
            }
            else if(a=='d'){
                r = '平';
            }
            else if(a=='a'){
                r = '负';
            }
        }
        return r;

    }
</script>
</html>